package org.example.aicloud.util;

import org.springframework.validation.BindException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;



@RestControllerAdvice
public class ExceptionAdvice {

    @ExceptionHandler(BindException.class)
    public ResultAjax handleBindException(BindException e) {
        return ResultAjax.error(e.getBindingResult().getAllErrors().get(0).getDefaultMessage());
    }

    @ExceptionHandler(Exception.class)
    public ResultAjax handleException(Exception e) {
        return ResultAjax.error(e.getMessage());
    }
}
